package cn.xc.feign;

import cn.xc.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserFeignClientFallbackFactory implements FallbackFactory<UserService> {
    @Override
    public UserService create(Throwable throwable) {

        return new UserService() {
            @Override
            public User getById(Long id) {
                //把信息打印到控制台
                throwable.printStackTrace();
                return new User(-1L,"触发熔断","网络异常，请稍后再试！");
            }
        };
    }
}